package cn.cjxy.springmvcdemo2.controller;

import cn.cjxy.springmvcdemo2.domain.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @author huangjie
 * @date 2025/10/13
 */
@RestController// @Controller  +@ResponseBody
public class JsonController {
    //返回json对象
    @RequestMapping("/getUser")
    public User getUser()
    {
        return new User("张三","123456");

    }
    //返回json数组
    @RequestMapping("/getUsers")
    public List<User> getUsers()
    {
        List<User> list = Arrays.asList(new User("张三", "123456"), new User("李四", "222222"), new User("王麻子", "654321"));

        return list;

    }
}
